#include <stdio.h>
#include <unistd.h> /*test porpase*/
#include <signal.h>

void setSigxcpuHandler(int signo,siginfo_t *info, void *context)
{
	fprintf(stdout,"catch SIGXCPU,need to hurty up\n");
}
void setSigprofHandler(int signo,siginfo_t *info, void *context)
{
	fprintf(stdout,"catch SIGPROF\n");
}
void readString(void* data)
{
	char buff[256]={'\0'};
	struct sigaction act;
	FILE *fd;
	act.sa_flags = SA_SIGINFO;
 	act.sa_sigaction = setSigxcpuHandler;
  	sigaction (SIGXCPU, &act, NULL);
  	fd=fopen("./makefile","r");
  	fread((void*)buff,sizeof(char),sizeof(buff)-1,fd);
//  	fprintf(stdout,"read: %s\n",buff);
	sleep(5);
}
void numberEnumerator(void* data)
{
	char ch;
	unsigned long long int enumerator=0;
	struct sigaction act;
	act.sa_flags = SA_SIGINFO;
 	act.sa_sigaction = setSigxcpuHandler;
 	fprintf(stdout,"enter nubner:\n");
	do{
		fscanf(stdin,"%c",&ch);
		switch (ch){
			case '0':
			enumerator+=0;
			break;
			case '1':
			enumerator+=1;
			break;
			case '2':
			enumerator+=2;
			break;
			case '3':
			enumerator+=3;
			break;
			case '4':
			enumerator+=4;
			break;
			case '5':
			enumerator+=5;
			break;
			case '6':
			enumerator+=6;
			break;
			case '7':
			enumerator+=7;
			break;
			case '8':
			enumerator+=8;
			break;
			case '9':
			enumerator+=9;
			break;
			case '\n':
			break;
			default:
			fprintf(stdout,"only number");
			_exit(1);
			break;
		}
	}while(ch!='\n');
	fprintf(stdout,"%lli\n",enumerator);
}
void sigChildIgn(void* data)
{}
void functionError(void *data)
{
	fprintf(stdout,"canot accomplish request\n");
}
